In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Psst... Ruszyły zawody olimpiady informatycznej dla uczniów szkół podstawowych i średnich. Zadania na tych konkursach są bardzo podobne do zadań, które rozwiązujesz, tutaj, na Szkopule. Zobacz więcej:
- dla uczniów szkół podstawowych: oij.edu.pl/start/
- dla uczniów szkół średnich: oi.edu.pl/l/jak_zaczac/
A dance party is held in a fire depot in Bytevillage and everyone in the village is invited to it.
For each dance the boys are paired with the girls so that the number of pairs formed is
as large as possible.
A girl and a boy can form a pair only if both of them know each other.
Definition.
A life of the party is such a person that if this person leaves the dance party,
the maximum number of pairs of boys and girls that can be formed decreases.
Yet another dance is planned at the party, but there is a problem:
the number of people currently present at the party exceeds by one the limit imposed
by Bytean fire regulations.
Some person has to be selected to exit the party and receive a free ticket for the
next party in return.
It was immediately decided that it is better not to select any person
who is a life of the party.
But who actually is a life of the party here?
Input
The first line of the input contains three integers
, and (, ) that represent the number of boys and girls and the number
of acquaintances.
The boys are numbered starting from 1, and also the girls are numbered starting from 1.
The following lines contain a description of the acquaintances.
Each of these lines contains two integers and
(, ) that represent an acquaintance
between the boy and the gal .
Output
Your program should output the numbers of persons being a life of the party, one
per line, first the boys, then the girls.
Each of the two lists should be sorted in ascending order.